//
//  Invoice_Vc.swift
//  Pods
//
//  Created by eme on 2017/4/5.
//
//


/*
 owner:cy
 update:2017年04月05日10:14:00
 info: 选择发票界面
 */
import RxSwift
import UtilCore
import RickonCore

class Invoice_Vc: Base_Vc {
    
    /****************************Storyboard UI设置区域****************************/
    @IBOutlet weak var change_Rbtn: RadioButton!
    
    @IBOutlet weak var submit_Btn: UIButton!
    
    /*----------------------------   自定义属性区域    ----------------------------*/
    
    var radioState:String?
    /// 修改状态
    var didUpdateState:((_ state:String) -> Void)?
    /****************************Storyboard 绑定方法区域****************************/
    
    
    
    /**************************** 以下是方法区域 ****************************/
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if let radioState = self.radioState {
            self.change_Rbtn.radioState = radioState
        }
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        
    }
    /**
     界面基础设置
     */
    override func setupUI() {
        /**
         *  自定义 导航栏左侧 返回按钮
         */
        self.customLeftBarButtonItem()
        submit_Btn.changeBorderColor(Theme.btn.normal, cornerRadius: 6.0)
        self.title = "发票信息"
        
    }
    /**
     app 主题 设置
     */
    override func setViewTheme(){
        
    }
    /**
     绑定到viewmodel 设置
     */
    override func bindToViewModel(){
         self.change_Rbtn
            .radioSubject
            .subscribe(onNext: { [unowned self] ( state ) in
                self.radioState = state
            })
            .disposed(by: disposeBag)
        self.submit_Btn
            .rx.tap
            .subscribe(onNext: { [unowned self] ( _ ) in
                if let didUpdateState = self.didUpdateState{
                    didUpdateState(self.radioState!)
                }
                _ = self.navigationController?.popViewController(animated: true)
                
            })
            .disposed(by: disposeBag)
    }
}
